package com.teach.sys.dao.dict;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author hzz
 */
@Mapper
public interface DictDao extends BaseMapper<Dict> {

	/**
	 * 类型列表
	 * @return
	 */
	@Select("SELECT type FROM sys_dict WHERE del_flag = '0' GROUP BY type ORDER BY type")
	List<String> findTypeList();
	
	/**
	 * 通过"类型"和"描述"获取字典值
	 * @return
	 */
	@Select("SELECT value FROM sys_dict WHERE del_flag = '0' AND type = #{type} and label = #{label}")
	String getDicValueByTypeAndLabel(String type,String label);

	/**
	 * 通过"类型"和"值"获取字典描述
	 * @return
	 */
	@Select("SELECT label FROM sys_dict WHERE del_flag = '0' AND type = #{type} and value = #{value}")
	String getDicValueByTypeAndValue(String type,String value);
	
	/**
	 * 通过"类型"字典值
	 * @return
	 */
	@Select("SELECT value, label  FROM sys_dict WHERE del_flag = '0' AND type = #{type} ORDER BY type, sort, update_date DESC")
	List<Map<String, String>> findDictByType(String type);
	/**
	 * 通过"类型"字典标签列表
	 * @return
	 */
	@Select("SELECT label  FROM sys_dict WHERE del_flag = '0' AND type = #{type} ORDER BY type, sort, update_date DESC")
	List<String> findLabelByType(String type);
	
}